﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WPFCanvas.CustomControls
{
    public class NodeInfoFactory
    {
        public static BaseNodeInfo NewNodeInfo(string typeInfo, string regID, string text,object tag)
        {
            var diType = (NodeType)Enum.Parse(typeof(NodeType), typeInfo);
            switch (diType)
            {
                case NodeType.RegNode:
                case NodeType.QueryNode:
                    return new QueryNodeInfo() { RegID = regID, Text = text, Tag = tag, ControlType = NodeType.QueryNode.ToString() };
            
            }

            return null;
        }

        public static BaseLineInfo NewLineInfo(BaseNodeInfo fromNode, BaseNodeInfo toNode, bool isRemark)
        {
          
            var fType = (NodeType)Enum.Parse(typeof(NodeType), fromNode.ControlType);
            var tType = (NodeType)Enum.Parse(typeof(NodeType), toNode.ControlType);
            
            switch (fType)
            {
                case NodeType.QueryNode:
                case NodeType.DataNode:
                    return new LineNodeInfo() { ControlType = NodeType.LineNode.ToString(), NodeFormID = fromNode.ControlID, NodeToID = toNode.ControlID, ParentID = fromNode.ControlID };
                case NodeType.CellNode:
                    return new QueryLineNodeInfo() { ControlType = NodeType.QueryLineNode.ToString(), NodeFormID = fromNode.ControlID, NodeToID = toNode.ControlID, ParentID = fromNode.ControlID };
            }

            return null;
        }

    }
}
